@extends('layouts.mobile_main')

@if(($useragent == 'FBWiOSApp') || ($useragent == "FBWAndroidApp"))
    @section('title', '新用户福利')
@endif

@section('resources')
    @parent
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <link rel="stylesheet" href="{{ env('CSS_DOMAIN') }}/css/public.css?v={{env('CSS_VERSION')}}">
    <script src="{{ env('JS_DOMAIN') }}/js/adaptation.js?v={{env('JS_VERSION')}}"></script>
@endsection

@section('content')
<div class="paysu_outer">
	<header class="pay_detail oh" style="background-color: #fff;">
		    <a class="fl" href="javascript:history.go(-1);"><img class="fl" src="{{env('IMAGE_DOMAIN')}}/images/back_p.png?v={{env('IMAGE_VERSION')}}" alt=""></a>
		<span class="fl co_violet fz_48">新用户福利</span>
	</header>
	<section class="welfare_center">
		<img class="background" src="{{env('IMAGE_DOMAIN')}}/images/firstcharge_bg.jpg?v={{env('IMAGE_VERSION')}}" alt="">
		<p class="user_info oh">
			<span class="fz_50 co_white fl">您的账号：</span>
			<input class="fl co_white" type="text" name="mobile" value="{{$mobile}}" readonly="readonly">
		</p>
		<a class="btn" onclick="get_double_coupon()">
		    <img src="{{env('IMAGE_DOMAIN')}}/images/firstcharge_btn.png?v={{env('IMAGE_VERSION')}}" alt="">
        </a>
	</section>
</div>
@endsection

@section('scriptResources')
    @parent
<script>
	window.onresize=function(){
		pagesp();
	}
	$(function(){
		var paysu_outer_h=$(window).height();
		$(".paysu_outer").css({"min-height":paysu_outer_h});
	})
	//刷新用户信息
      function refreshUserInfo(){
        MobileJS.refreshUserInfo();
        // console.log()
      }
    // alert(window.location.href)    //打印当前页面url
	if(navigator.userAgent=='FBWAndroidApp'||navigator.userAgent.indexOf('FBWiOSApp')>0){
		$("header").hide();
	}else{
		$("header").show();
	}
	function get_double_coupon() {
	    var mobile = $("input[name='mobile']").val();
	    $.ajax({
	        url:"/mobile/wallet/doublecoupon/get",
            type: "get",
            data: {mobile: mobile},
            dataType:'json',
            success:function(data){
                if(data.status == 'success') {
                	if(navigator.userAgent=='FBWAndroidApp'||navigator.userAgent.indexOf('FBWiOSApp')>0){
                		refreshUserInfo()
                		alert("领取成功 可在 我的翻倍券 中查看");
                	}else{
                		alert("领取成功 可在 我的翻倍券 中查看");
                	}
                } else {
                    alert("你已经领取了，请点击左上角返回按钮,前往'我的'页面查看");
                }
            }
	    });
	}
</script>
@endsection